package com.stone.business.tabl.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.stone.business.tabl.pojo.TTablXsb;
import com.stone.business.tabl.service.TablService;
import com.stone.utils.ParamsBean;
import com.stone.utils.StringUtils;

import frm.ssh.action.BaseListAction;

public class TablXsbListAction extends BaseListAction {
	private static final long serialVersionUID = -7339292494762150558L;
	private TablService tablService;
	private ArrayList<ParamsBean> statusList = new ArrayList<ParamsBean>();
	public TablXsbListAction() {
		this.entityClass = TTablXsb.class;
	}

	public TablService getTablService() {
		return tablService;
	}

	public void setTablService(TablService tablService) {
		this.tablService = tablService;
		this.service=tablService;
	}

	public ArrayList<ParamsBean> getStatusList() {
		statusList.add(new ParamsBean("01", "项目可研"));
		statusList.add(new ParamsBean("02", "设备命名建议"));
		statusList.add(new ParamsBean("03", "初步设计、设备选型、技术协议、正式设计"));
		statusList.add(new ParamsBean("04", "安装调试"));
		statusList.add(new ParamsBean("05", "下达正式命名及编号、计算并下达保护定制"));
		statusList.add(new ParamsBean("07", "制定送电计划"));
		statusList.add(new ParamsBean("08", "编制启动送电措施"));
		statusList.add(new ParamsBean("09", "生产副总工审批"));
		statusList.add(new ParamsBean("06", "审批驳回"));
		statusList.add(new ParamsBean("10", "提交送电申请"));
		statusList.add(new ParamsBean("11", "送电结束"));
		statusList.add(new ParamsBean("12", "材料归档"));
		statusList.add(new ParamsBean("13", "材料归档完成"));
		return statusList;
	}

	public void setStatusList(ArrayList<ParamsBean> statusList) {
		this.statusList = statusList;
	}

	public HashMap<String, Object> setSearchCondition() {
		HashMap<String, Object> m = new HashMap<String, Object>();
		List<Object> valsList = new ArrayList<Object>();
//		TUser loginUser  = (TUser)super.getSession().getAttribute(IConstant.SESSION_TUSER);//系统当前登录用户
//		String organCode = String.valueOf(super.getSession().getAttribute(IConstant.SESSION_TORGAN_CODE));
		m.put("cols", "new map(tablxsb.id as id,TO_CHAR(tablxsb.startdate,'yyyy-MM-dd') as startdate,tablxsb.realname as realname,tablxsb.bh as bh,tablxsb.fqr as fqr,tablxsb.status as status)");
		String conditions = " 1= 1 ";
		
		// 开始时间
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon2())){
			conditions += " AND TO_CHAR(tablxsb.startdate,'yyyy-MM-dd') >= ?";
			valsList.add(super.getSearchBean().getCon2());
		}
		
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon3())){
			conditions += " AND TO_CHAR(tablxsb.startdate,'yyyy-MM-dd') <= ?";
			valsList.add(super.getSearchBean().getCon3());
		}
		
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon4())){
			conditions += " AND tablxsb.status = ?";
			valsList.add(super.getSearchBean().getCon4());
		}
		
		m.put("conditions",conditions);
		m.put("clause"," order by tablxsb.startdate asc");
		m.put("alias", "tablxsb");
		m.put("vals", valsList.toArray());
		return m;
	}

}
